<html>
<head><meta charset="utf-8"><title>matching again projection List&lt;T&gt; · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html">matching again projection List&lt;T&gt;</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177947207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947207">(Oct 11 2019 at 20:41)</a>:</h4>
<p>we were talking about matching <code>Place</code> now that after interning instead of having <code>Box&lt;[T]&gt;</code> we will have <code>&amp;List&lt;T&gt;</code></p>



<a name="177947214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947214">(Oct 11 2019 at 20:41)</a>:</h4>
<p>/cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="177947284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947284">(Oct 11 2019 at 20:42)</a>:</h4>
<p>what I'm mainly doing is calling <code>Place::as_ref()</code> to get a <code>PlaceRef</code> which holds <code>&amp;[T]</code> instead of <code>&amp;List&lt;T&gt;</code></p>



<a name="177947321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947321">(Oct 11 2019 at 20:42)</a>:</h4>
<p>so trivial cases are not thaaat bad</p>



<a name="177947338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947338">(Oct 11 2019 at 20:42)</a>:</h4>
<p>the problem is once the pattern is more complex, like having Place inside other things</p>



<a name="177947349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947349">(Oct 11 2019 at 20:42)</a>:</h4>
<p>patterns like <code>Operand(Place { ... })</code> are now not directly possible</p>



<a name="177947359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947359">(Oct 11 2019 at 20:42)</a>:</h4>
<p>yeah I mean at the end of the day I think you just need nested matches sometimes</p>



<a name="177947372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947372">(Oct 11 2019 at 20:43)</a>:</h4>
<p>maybe point to some particularl examples?</p>



<a name="177947384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947384">(Oct 11 2019 at 20:43)</a>:</h4>
<p>need to translate to <code>Operand(place)</code> and then match over <code>place.as_ref()</code> or things like that</p>



<a name="177947387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947387">(Oct 11 2019 at 20:43)</a>:</h4>
<p>tbqh I sort of prefer helper functions describing patterns where possible anyway</p>



<a name="177947404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947404">(Oct 11 2019 at 20:43)</a>:</h4>
<p>but I might just have stockholm syndrome</p>



<a name="177947423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947423">(Oct 11 2019 at 20:43)</a>:</h4>
<p>I feel like there's some syndrome where compiler authors avoid complex features because they know what a pain they are to implement</p>



<a name="177947439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947439">(Oct 11 2019 at 20:43)</a>:</h4>
<p>that's how I presently feel about slice patterns :P</p>



<a name="177947596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947596">(Oct 11 2019 at 20:45)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L497" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L497">https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L497</a></p>



<a name="177947668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947668">(Oct 11 2019 at 20:46)</a>:</h4>
<blockquote>
<p>I feel like there's some syndrome where compiler authors avoid complex features because they know what a pain they are to implement</p>
</blockquote>
<p>LOL</p>



<a name="177947952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177947952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177947952">(Oct 11 2019 at 20:49)</a>:</h4>
<p>link doesn't work for me</p>



<a name="177948062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948062">(Oct 11 2019 at 20:50)</a>:</h4>
<p>fixed</p>



<a name="177948070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948070">(Oct 11 2019 at 20:50)</a>:</h4>
<p>sorry, in a particular branch</p>



<a name="177948339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948339">(Oct 11 2019 at 20:53)</a>:</h4>
<p>yeah so that's a case where I would sort of prefer the <code>as_local</code> function</p>



<a name="177948353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948353">(Oct 11 2019 at 20:53)</a>:</h4>
<p>that said</p>



<a name="177948371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948371">(Oct 11 2019 at 20:53)</a>:</h4>
<p>how often is the pattern the "empty list"?</p>



<a name="177948379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948379">(Oct 11 2019 at 20:53)</a>:</h4>
<p>i.e., <code>box []</code></p>



<a name="177948411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948411">(Oct 11 2019 at 20:54)</a>:</h4>
<p>A <code>Place::local</code> combinator that returns <code>Some(local)</code> when the place has no projections would remove many places where you need to match on the projections directly, at least in the code I've been working on.</p>



<a name="177948433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948433">(Oct 11 2019 at 20:54)</a>:</h4>
<p>that <em>might</em> be something we could do with a constant</p>



<a name="177948440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948440">(Oct 11 2019 at 20:54)</a>:</h4>
<blockquote>
<p>A <code>Place::local</code> combinator that returns <code>Some(local)</code> when the place has no projections and would remove many places where you need to match on the projections directly, at least in the code I've been working on.</p>
</blockquote>
<p>there is one</p>



<a name="177948450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948450">(Oct 11 2019 at 20:54)</a>:</h4>
<p>I landed it -- I think? -- as part of some PR</p>



<a name="177948463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948463">(Oct 11 2019 at 20:54)</a>:</h4>
<p><code> place.as_local()</code> I think?</p>



<a name="177948500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948500">(Oct 11 2019 at 20:54)</a>:</h4>
<p>I'll check. I've seen <code>local_or_deref_local</code>.</p>



<a name="177948508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948508">(Oct 11 2019 at 20:54)</a>:</h4>
<p>maybe I can look for better examples :)</p>



<a name="177948581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948581">(Oct 11 2019 at 20:55)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.Place.html#method.as_local" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.Place.html#method.as_local">Place::as_local</a></p>



<a name="177948598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/matching%20again%20projection%20List%3CT%3E/near/177948598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/matching.20again.20projection.20List.3CT.3E.html#177948598">(Oct 11 2019 at 20:55)</a>:</h4>
<p>time to rewrite some stuff :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>